#ifndef LUAUTIL_H_
#define LUAUTIL_H_

extern "C"
{

		
#include <luajit-2.0/luajit.h>
#include <luajit-2.0/lua.h>
#include <luajit-2.0/lauxlib.h>
		
}

#include "gameinterface.h"
#include <string>


#ifndef lua_rawlen
#define lua_rawlen lua_objlen
#endif

#ifndef RegisterNameSpace
#define RegisterNameSpace( l, n ) \
	lua_getglobal( l, n ); \
	if( lua_isnil( l, -1 ) == 0 ){ lua_pushnil( l ); lua_setglobal( l, n ); lua_pop( l, 1 ); } else{ lua_pop( l, 1 ); } \
	lua_createtable( l, 0, 0 ); \
	lua_setglobal( l, n )
#endif


#define RegisterNameSpaceFunction( l, n, s, f ) \
	lua_getglobal( l, n ); \
	lua_pushcfunction( l, f ); \
	lua_setfield( l, -2, s ); \
	lua_pop( l, 1 );
	
#define RegisterFunction( l, s, f ) \
	lua_pushcfunction( l, f ); \
	lua_setglobal( l, s );

float LuaStringKeyFloatValue( lua_State *, int, std::string );
int LuaStringKeyIntValue( lua_State *, int, std::string );
std::string LuaStringKeyStringValue( lua_State *, int, std::string );

void LuaGetEntityTable( lua_State *, int );

extern CGameInterface * g_pGameInterface;


#endif
